/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package angrypainters.application;

import angrypainters.components.Message;
import angrypainters.components.MessageType;
import angrypainters.components.NetworkManager;
import angrypainters.components.ResourceManager;
import angrypainters.components.ScreensManager;
import angrypainters.components.Settings;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TableView;
import javafx.scene.text.Text;

/**
 *  Controller class for the start screen
 *
 * @author A7med
 */
public class StartScreenController implements Initializable {

    private ScreensManager sc;
    @FXML
    Button settings;
    private ResourceManager manager;
    private NetworkManager netManager;
    private Settings option;
    @FXML
    TableView connectionTable;
    @FXML
    Text text;
    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    

    public ScreensManager getSc() {
        return sc;
    }

    public void setSc(ScreensManager sc) {
        this.sc = sc;
    }
    /**
     * display the setting screen
     * @param e 
     */
    public void displaySettings(ActionEvent e){
        sc.addScreen("settings", manager.getSettingsScreen());
        sc.setScreen("settings");
    }
    /**
     * display the game screen
     * @param e 
     */
     public void displayGame(ActionEvent e){
        sc.addScreen("game", manager.getMain());
        sc.setScreen("game");
    }
     
     public void quit(ActionEvent event){
         Platform.exit();
     }
    public ResourceManager getManager() {
        return manager;
    }

    public void setManager(ResourceManager manager) {
        this.manager = manager;
    }

    public NetworkManager getNetManager() {
        return netManager;
    }

    public void setNetManager(NetworkManager netManager) {
        this.netManager = netManager;
    }
    public void startListning(){
        netManager.recieveData();
    }
    public void sendRequet(){
        netManager.sendData(new Message(MessageType.Request, option));
        startListning();
    }

    public Settings getOption() {
        return option;
    }

    public void setOption(Settings option) {
        this.option = option;
    }
    
}
